<template>
  <div class="all">
    <layheade>
      <span slot="head-title" class="head-title">设置</span>
    </layheade>
    <div class="user-info">
      <!-- 头像行 -->
      <div class="row">
        <span class="row-l">头像</span>
        <div class="row-r">
          <van-uploader :after-read="afterRead" capture image-fit="cover">
            <img :src="fileList[0].url" alt />
          </van-uploader>
          <van-icon name="arrow" />
        </div>
      </div>
      <!-- 用户名行 -->
      <div class="row">
        <span class="row-l">用户名</span>
        <div class="row-r" @click="nameshow=true">
          <span>{{namevalue}}</span>
          <van-icon name="arrow" />
        </div>
      </div>
      <!-- 用户名修改 -->
      <van-popup v-model="nameshow" position="bottom" :style="{ height: '20%' }">
        <van-field v-model="namevalue" placeholder="请输入要修改的用户名" :border="true" />
      </van-popup>
      <!-- 性别行 -->
      <div class="row" @click="gendershow=true">
        <span class="row-l">性别</span>
        <div class="row-r">
          <span>男</span>
          <van-icon name="arrow" />
        </div>
      </div>
      <!-- 性别修改 -->
      <van-popup v-model="gendershow" position="bottom" :style="{ height: '20%' }">
        <van-picker :columns="columns" @change="onChange" />
      </van-popup>
      <div class="row">
        <span class="row-l">年龄</span>
        <div class="row-r">
          <span>26</span>
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="row">
        <span class="row-l">地区</span>
        <div class="row-r">
          <span>广东深圳</span>
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="row">
        <span class="row-l">个性签名</span>
        <div class="row-r">
          <span>个性潮流女装应有尽有</span>
          <van-icon name="arrow" />
        </div>
      </div>
    </div>
    <div class="footer">
      <van-button color="#FE5530FF" size="large">完成</van-button>
    </div>
  </div>
</template>

<script>
import layheade from "../components/layheade.vue";
export default {
  components: {
    layheade
  },
  data() {
    return {
      fileList: [
        {
          url: require("../../../assets/images_test/0.png")
        }
      ],
      nameshow: false,
      namevalue: "煎饼果子",
      gendershow: false,
      columns: ["男", "女", "保密"]
    };
  },
  methods: {
    // 头像文件上传信息
    afterRead(file) {
      // 将文件上传至服务器
      console.log(file.content);
      this.fileList.url = file.content.data;
    },
    // 性别
    onChange(picker, value, index) {
      this.$toast(`当前值：${value}, 当前索引：${index}`);
    }
  }
};
</script>

<style lang="less" scoped>
.all {
  background-color: #f8f8f8ff;
  width: 100%;
  height: 100%;
}

.user-info {
  margin-top: 8px;
  .row {
    width: 100%;
    height: 46px;
    background-color: #fff;
    border-top: 1px solid #f8f8f8ff;
    border-bottom: 1px solid #f8f8f8ff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 22px;
    &:nth-child(1) {
      height: 70px;
      img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
      }
    }
    .row-l {
      font-size: 15px;
      font-weight: 600;
    }

    .row-r {
      display: flex;
      align-items: center;
      span {
        font-size: 15px;
        color: #787878ff;
      }
      .van-icon-arrow {
        font-size: 20px;
        color: #787878ff;
      }
    }
  }
}
.footer {
  width: 333px;
  position: fixed;
  left: 21px;
  bottom: 80px;
}
</style>